/*
 * @Description  : Prensent算法配合SRAM模块
 * @authorName   : GuoJi
 * @github       : https://github.com/guoji-kk
 * @gitee        : https://gitee.com/guoji13663585559
 * @email        : 13663585559@163.com
 * @version      : 1.0
 * @Date         : 2023-06-04 20:01:22
 * @LastEditTime : 2023-06-04 20:45:09
 */

module present_sram_top(
     input clk,
	   input clk_uart,
     input start,
	   output uart_txd, 
     output reg [63:0] result
);

wire[79:0] data_i; 
wire[63:0] data_o; 
wire key_load; 
wire data_load; 
wire valid;


present_encryptor_top encry_u (
   .data_o(data_o),
   .data_i(data_i),
   .data_load(data_load),
   .key_load(key_load),
   .clk(clk),
   .encry_ok(valid)
);

sram_ctl sram_ctl_u(
   .clk(clk),
   .rd_en(start),
   .wr_en(valid),
   .data_in(data_o),
   .data_out(data_i),
   .key_load(key_load),
   .data_load(data_load) 
);

  uart_send64 uart_u(
  .sys_clk(clk_uart),
  .sys_rst_n(start),
  .uart_en(valid),
  .uart_din(data_o),
  .uart_txd(uart_txd)
  );

always@(posedge clk)
begin
  if(valid)
  result = data_o;
  else 
  result = 0;
end


endmodule